<?php

namespace App\Http\Controllers\car;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use DB;
class PayController extends Controller
{
    //把选定的地址给订单
    public function index(Request $request){
        //dd($request);
        $order_id = $request->only('order_id');
        $a = $request->only('order_id')['order_id'];
        $order_id = implode($order_id);
        $order_id = explode(",",$order_id);
        $reveive_address_id = $request->only('reveive_address_id')['reveive_address_id'];
        array_pop($order_id);
        foreach($order_id as $k=>$v){
        	DB::table('myorder')->where('product_id',$v)->update(['reveive_address_id'=>$reveive_address_id]);
        }
       return view('car.parfor',['order_id'=>"$a"]);
    }
    public function edit($id){
        $a = DB::table('myorder')->where('id',$id)->pluck('product_id')[0];
        //dd($a);
        return view('car.parfor',['order_id'=>"$a,"]);
    }
        
    public function update(Request $request){
    //修改订单状态为已支付
    	//dd($request);
        $order_id = $request->only('order_id');
        $order_id = implode($order_id);
        $order_id = explode(",",$order_id);
        $user_id = session('homeuser')->id;
        array_pop($order_id);
        foreach($order_id as $k=>$v){
            DB::table('myorder')->where('product_id',$v)->where('user_id',$user_id)->where('status',1)->update(['status'=>2]);
        }
        return view("car.sucesspay");
    }	
   
    
}
